#include <pthread.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "LoadConfig.h"

#include <log4cplus/configurator.h>
#include "HandleMgr.h"

using namespace log4cplus;
using namespace std;

int main(int argc,char *argv[])
{
    char property_file[256]; 

	strcpy(property_file, "../conf/bncf.conf");

	PropertyConfigurator::doConfigure("../conf/log4cplus.properties");

    daemon(1,1);

    signal(SIGPIPE, SIG_IGN);
	signal(SIGIO, SIG_IGN);
	signal(SIGINT, SIG_IGN);
	signal(SIGALRM, SIG_IGN);
	signal(SIGCLD, SIG_IGN);
    signal(SIGHUP,SIG_IGN);

    g_LoadConfig_Mgr::instance().load_config(string(property_file));

    HandleMgr handle_Mgr;

    if(!handle_Mgr.init())
    {
        return 0;
    }

    if(!handle_Mgr.start())
    {
        return 0;
    }

    handle_Mgr.wait_end();
    
    return 0;
}
